pub use sea_orm::entity::prelude::*;

use crate::{add_relate, booking_status};

#[derive(Debug, Clone, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "meet_room")]
pub struct Model {
    /// 每个会议室唯一ID
    #[sea_orm(primary_key)]
    pub id: i64,

    /// 每个会议室名称
    #[sea_orm(type = "String(Some(16))")]
    pub name: String,
    /// 会议室最大承载人数
    pub max_people_number: u32,
    #[sea_orm(default = "None")]
    pub delete_at: Option<DateTime>,
}

#[derive(Debug, Clone, Copy, EnumIter)]
pub enum Relation {
    BookingStatus,
}

impl RelationTrait for Relation {
    fn def(&self) -> RelationDef {
        match self {
            Relation::BookingStatus => Entity::has_many(booking_status::Entity).into(),
        }
    }
}

add_relate! {
    booking_status::Entity => Entity | Relation::BookingStatus
}

impl ActiveModelBehavior for ActiveModel {}
